package org.example.single;

/**
 * @author wangjie
 * @since 2024.11.7
 * 使用内部类创建单例模式
 */
public class StaticSingleton {

    private StaticSingleton() {
        System.out.println("创建耗时的单例类");
    }

    private static class SingletonHolder {
        private static final StaticSingleton INSTANCE = new StaticSingleton();
    }

    public static StaticSingleton getInstance() {
        return SingletonHolder.INSTANCE;
    }
}
